from django.db import models
# Create your models here.

# 用户
class User(models.Model):
    # 邮箱,密码,手机号,用户名,地址,头像路径,账号状态,注册时间
    
    uname = models.CharField(max_length=20)
    upwd = models.CharField(max_length=140)
    uemail = models.CharField(max_length=30)
    uphone = models.CharField(max_length=11,default='')
    uQQ = models.CharField(max_length=100,default='')
    uimgurl = models.CharField(max_length=100, null=True)
    # # ustatus: 用户账号状态  0: 正常  1: 禁用  -1: 已经注销
    ustatus = models.IntegerField(default=0) # 默认正常
    uaddtime = models.DateTimeField(auto_now_add=True)

# 商品种类信息
class Category(models.Model):
    # 商品种类名称,编号,分类路径
    cname = models.CharField(max_length=50)
    cid = models.IntegerField()
    cpath = models.CharField(max_length=50)

# 商品具体信息
class Goods(models.Model):
    # 名称,图片路径,价格,商品数量,商品描述,商品状态,点击量,添加时间,外键
    gname = models.CharField(max_length=100)
    gimgurl = models.CharField(max_length=200)
    gprice = models.IntegerField(null=True)
    gordernum = models.IntegerField(null=True)
    ginfo = models.TextField()
    # gstatus: 商品状态  0: 正常  1:缺货   -1: 下架
    gstatus = models.IntegerField(default=0)
    gclicknum = models.IntegerField(default=0)
    gaddtime = models.DateTimeField(auto_now_add=True)
    categoryid = models.ForeignKey(to="Category",to_field="id",on_delete=models.CASCADE,default=None)